package leetcode1;

public class Day11 {
    public int jump(int[] nums) {
        int ret=0;
        int n=nums.length;
        int left=0,right=0,i=0;
        //if(n==1) return 0;
        while(i < n-1) {
            ret++;//跳跃次数+1
            left=right+1;
            while(i<left) {
                right=Math.max(nums[i]+i,right);
                if(right>=n-1) return ret;
                i++;
            }
        }
        return ret;
    }
}
